﻿<!DOCTYPE>

<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>产品加工试样信息维护</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <style type="text/css">
        .linkbutton{margin-left:20px;}
         table tr td{padding:0px 5px}
         .divLabel2 td{text-align: end;text-align: left;font-size:12px;}
         .divLabel{display:none;}
    </style>
</head>
<body>
 <div class="panelSection">    
        <div class="easyui-panel " title="查询区域" style="padding:3px;width: 100%" 
        data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
        <form id="searchForm" style="margin-bottom: 2px;">
               <table>
                <tr class="divLabel2">
                    <td>零件号：</td>
                    <td>工序：</td>
                </tr>
                <tr>
                    <td><input id="txtProductName" class="easyui-textbox" name="ProductName" type="text" style="width: 120px; height: 22px" /></td>
                    <td><input id="txtWorkflowStepName" class="easyui-textbox" name="WorkflowStepName" type="text" style="width: 120px; height: 22px" /></td>
                    <td><a href="javascript:void(0)" id="btnSearch" class="easyui-linkbutton"   onclick="page.searchData()">查询</a>
                    <a href="javascript:void(0)" id="btnReset" class="easyui-linkbutton"   onclick="page.searchReset()">重置</a>
                    </td>
                </tr>
            </table>
        </form> 
        </div> 
    </div> 
      <div class="panelSection">    
        <div class="easyui-panel " title="产品加工试样信息" style="padding:3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
        <div class="easyui-layout" style="width:100%;height:400px;">
                <table id="ProductProcessSampleTable" style="height:363px;width:100%"></table>
                     <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                         layout:['first','prev','next','last','manual','info'],              
                            total: 0,
                            showPageList: false,
                            showPageInfo: false,
                            showRefresh: false,
                            afterPageText:'共&nbsp{pages}&nbsp页',
                             buttons:[{
                                    iconCls:'',
                                    text:'Go',
                                    id:'pageGo'
                            }]
                        ">
                            </div>
	</div>
        </div>
        <form id="EditorForm">
                  <table class="tabel" cellpadding="5">
	    		    <tr class="divLabel2">
	    			    <td>零件号</td>
                        <td>工序号</td>
                        <td>试样规格</td>
                        <td>试样材料</td>
                        <td>试样状态</td>
                        <td>试样数量</td>
                        <td>备注</td>
	    		    </tr>
	    		    <tr>
	    			    <td><input  type="hidden" name="ProductProcessSampleId" style="width:150px; height:22px;display:none"  id="ProductProcessSampleId"/>
                        <input  type="hidden" name="ProductName" style="width:150px; height:22px;display:none" id="ProductName" />
                        <div id="productCombox"></div></td>
	    			    <td><input class="easyui-combobox" type="text" name="WorkflowStepName" style="width: 150px; height: 22px" id="workflowstep"/></td>
                        <td><input class="easyui-textbox" type="text" name="SampleSpecification" style="width: 150px; height: 22px" id="SampleSpecification"/></td>
	    			    <td><input class="easyui-textbox" type="text" name="SampleMaterial" style="width: 150px; height: 22px"  id="SampleMaterial"/></td>
                        <td><input class="easyui-textbox" type="text" name="SampleStatus" style="width: 150px; height: 22px" id="SampleStatus"/></td>
                        <td><input class="easyui-numberbox" type="text" name="SampleQty" style="width: 150px; height: 22px"id="SampleQty"/></td>
                        <td><input class="easyui-textbox" type="text" name="Notes" style="width: 500px; height: 22px" id="Notes"/></td>
	    		    </tr>
	    	    </table>
              </form>
      </div>
      
      <div class="panelSection">    
        <div class="easyui-panel " title="按钮区域" style="padding:3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
            <div style="margin:15px 0px">
                  <a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.AddSample(0)">新增</a>
                  <a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.AddSample(1);">修改</a>
                  <a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.DelSample();">删除</a>
            </div>
      </div>
      </div>
      <div id="statusMessage" style="font-size: 14px; height: 40px"></div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/array.pollyfill.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ProductLinkageWorkflow.js"type="text/javascript"></script>

<script type="text/javascript">
/*
创建人：longb
日期：2025-08-21
描述：产品加工试样信息
*/
var page = {
    pagetotal: 0,
    pageSize: 20,
    pageNumber: 1,
    factoryName:null,
    ajaxUrl: getRootPath() + "/Ashx/ProductProcessSampleHandler.ashx",
    commonUrl: getRootPath() + "/Ashx/CommonHandler.ashx", //通用方法后台路径
    //初始化页面
    init: function () {
        page.bind();
        NewcustomizedEasyuiPagination('pp'); //定制化分页
        $('#pp').find('.pageSize').val(page.pageSize); //初始化行数
    },
    //页面事件绑定
    bind: function () {
        //产品加工试样信息
        $("#ProductProcessSampleTable").datagrid({
            checkOnSelect: false,
            selectOnCheck: false,
            singleSelect: true,
            rownumbers: true,
            onLoadSuccess: function (data) {
                $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                    total: page.pagetotal,
                    pageSize: page.pageSize,
                    pageNumber: page.pageNumber
                });
                NewcustomizedEasyuiPagination('pp'); //定制化分页
            },
            columns: [[
                 { field: 'ck', title: '选择', checkbox: true },
                 { field: 'PRODUCTNAME', title: '零件号', width: 150 },
                 { field: 'WORKFLOWSTEPNAME', title: '工序', width: 150 },
                 { field: 'SAMPLESPECIFICATION', title: '试样规格', width: 150 },
                 { field: 'SAMPLEMATERIAL', title: '试样材料', width: 100 },
                 { field: 'SAMPLESTATUS', title: '试样状态', width: 170 },
                 { field: 'SAMPLEQTY', title: '试样数量', width: 120 },
                 { field: 'NOTES', title: '备注' }
	           ]],
               onSelect:function(index, row){
                 $('#EditorForm').form('load',{
                    ProductProcessSampleId:row.PRODUCTPROCESSSAMPLEID,
                    ProductName:row.PRODUCTNAME,
                    WorkflowStepName:row.WORKFLOWSTEPNAME,
                    SampleSpecification:row.SAMPLESPECIFICATION,
                    SampleMaterial:row.SAMPLEMATERIAL,
                    SampleStatus:row.SAMPLESTATUS,
                    SampleQty:row.SAMPLEQTY,
                    Notes:row.NOTES,
                    accept:true
                });
                $('#txtproductCombox').textbox("setValue",row.PRODUCTNAME);
               },
        });
        //分页事件
        $('#pp').pagination({
            onSelectPage: function (pageNumber, pageSize) {
                NewcustomizedEasyuiPagination('pp'); //定制化分页
                page.pageSize = pageSize; page.pageNumber = pageNumber;
                page.getProductProcessSample();
            }
        });
        //绑定分页go按钮
        $('#pageGo').on("click", function () {
            var pageNumber = $(this).parents('tr').find('.pagination-num').val();
            page.pageNumber = pageNumber;
            page.pageSize=$('#pp').find('.pageSize').val() == "" ? page.pageSize : Number($('#pp').find('.pageSize').val());
            page.getProductProcessSample();
        });
        //清除按钮
        $('#btnReset').on("click", function () {
            page.reset(true, true,true);
        });
        $("#productCombox").productCombo({
            search: function () {
            },
            cancel: function () { //件号取消点击事件
              $("#workflowstep").combobox('clear').combobox('loadData',[]);
            },
            selected: function (val, text) {//件号下拉选择事件
              $('#ProductName').val(text);
              page.getWorkflowStepByProductId(val);
            }
        });
    },
    //查询件号对应工艺工序
    getWorkflowStepByProductId(productid){
        page.post(null, { action: "GetWorkflowStepData", productid: productid }, function (res) {
                $("#workflowstep").combobox({
                    valueField: 'WORKFLOWSTEPNAME',
                    textField: 'WORKFLOWSTEPNAME',
                    panelHeight: 200,
                    data: res.DBTable //下拉数据
                });
        });
    },
    //查询
    searchData: function () {
        page.reset(false,true,true);
        page.pageNumber = 1;
        page.getProductProcessSample();
    },
    //查询产品加工试样信息
    getProductProcessSample: function () {
        var frdata = $('#searchForm').serializeArray();
        var data = {};
        $.each(frdata, function () {
            data[this.name] = this.value
        });
        var param = {
            action: "GetProductProcessSample",
            pageSize: page.pageSize,
            pageNumber: page.pageNumber,
            data: JSON.stringify(data)
        };
        page.post(null,param, function (res) {
            if (res.Result) {
                page.pagetotal = res.RowCount;
                $('#ProductProcessSampleTable').datagrid('loadData', res.DBTable);
            }
        });
    },
    AddSample:function(type){
        var frdata = $('#EditorForm').serializeArray();
        var data = {};
        $.each(frdata, function () {
            data[this.name] = this.value
        });
        if(data.ProductProcessSampleId==''&&type==1){
            displayMessage("请选择一条记录再进行修改操作", false); return;
        }
        if(data.ProductName==''){
            displayMessage("请选择零件号", false); return;
        }
        if(data.WorkflowStepName==''){
            displayMessage("请选择工序", false); return;
        }
        if(data.SampleSpecification==''){
            displayMessage("请输入试样规格", false); return;
        }
        if(data.SampleMaterial==''){
            displayMessage("请输入试样材料", false); return;
        }
        if(data.SampleStatus==''){
            displayMessage("请输入试样状态", false); return;
        }
        if(data.SampleQty==''){
            displayMessage("请输入试样数量", false); return;
        }

         var param = {
            action: "SaveProductProcessSample",
            data: JSON.stringify(data)
         }
         page.post(null,param, function (res) {
            if (res.Result) {
              page.getProductProcessSample();
              page.clearEditorForm();
            }
            displayMessage(res.Message,res.Result);
        });
    },
    DelSample:function(){
        var rows = $("#ProductProcessSampleTable").datagrid('getChecked'); //获取勾选的行
        if(rows.length==0){
            displayMessage("请选择数据再进行操作", false);
            return;
        }
        var ids=rows.map(item=>item.PRODUCTPROCESSSAMPLEID).join(',');
         $.messager.confirm('确认', '你确认要【删除】吗?', function (r) {
                if(r){
                page.post(page.url, { action: "DeleteProductProcessSample",ids: ids }, function (res) {
                    if (res.Result) {
                       page.getProductProcessSample();
                       page.clearEditorForm();
                    } 
                   displayMessage(res.Message, res.Result);
                });}
            });
    },
    clearEditorForm:function(){
        $("#workflowstep").combobox('clear');
        $('#SampleSpecification').textbox('setValue','');
        $('#SampleMaterial').textbox('setValue','');
        $('#SampleStatus').textbox('setValue','');
        $('#SampleQty').textbox('setValue','');
        $('#Notes').textbox('setValue','');
        $('#ProductProcessSampleId').val('');
    },
    //查询重置
    searchReset: function () {
        page.reset(true,true,true);
    },

    //清除方法，重要！！！
    reset: function (iscondition, isresult, isDetail) {
        clearMessage();
        if (iscondition) {
            $("#txtProductName").textbox("setValue", ""); //订单号
            $("#txtWorkflowStepName").textbox("setValue", ""); //件号
        }

        if (isresult) {
            clearEasyuiDataGrid("ProductProcessSampleTable", 1); //查询结果列表
            $('#EditorForm').form('clear');
            page.pageNumber = 1; page.pagetotal = 0;//重置分页
            $('#pp').pagination('refresh', {
                total: page.pagetotal,
                pageSize: page.pageSize,
                pageNumber: page.pageNumber
            });
        }
        if(isDetail)
        {
            
        }
    },
    //post数据
    post: function (url,param, callback) {
        $.ajax({
            type: "Post",
            url:url==null?page.ajaxUrl:url,
            data: param,
            cashe: false,
            async: true,
            dataType: "json",
            beforeSend: function () {
                $.messager.progress({ text: '', msg: '处理中...' });
            },
            success: function (data) {
                $.messager.progress('close');
                callback(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.progress('close');
                displayMessage(XMLHttpRequest.responseText, false);
            }
        });
    }
}
//$(function () {
    page.init();
//});

</script>
